<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Integer_field extends Db_field
{
	// Set the defaults
	protected $defaults = array(
		'data_type' => 'INT',
		'data_length' => 10, // Default display width for MySQL. TODO: make defaults per database, and allow user to set
		'auto_increment' => false,
		'primary_key' => false,
		'unsigned' => false,
		'index' => false,
		'allow_null' => true
	);
	
	public function __construct(Array $properties)
	{
		// Extend defaults with passed-in properties
		$properties = array_merge($this->defaults, $properties);
		
		// Check for allow_null (primary_key issue)
		if($properties['primary_key'])
		{
			$properties['allow_null'] = false;
		}
		
		parent::__construct($properties);
	}
} // end Integer_field